/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package library.provider;

import java.util.Collection;
import java.util.Date;
import java.util.List;

import library.LibraryPackage;
import library.RentRecord;

import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
import org.eclipse.emf.edit.provider.ViewerNotification;

/**
 * This is the item provider adapter for a {@link library.RentRecord} object.
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * 
 * @generated
 */
public class RentRecordItemProvider extends ItemProviderAdapter implements
		IEditingDomainItemProvider, IStructuredItemContentProvider,
		ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource {
	/**
	 * This constructs an instance from a factory and a notifier. <!--
	 * begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public RentRecordItemProvider(AdapterFactory adapterFactory) {
		super(adapterFactory);
	}

	/**
	 * This returns the property descriptors for the adapted class. <!--
	 * begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */

	public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
		if (itemPropertyDescriptors == null) {
			super.getPropertyDescriptors(object);

			addRenterPropertyDescriptor(object);
			addBookPropertyDescriptor(object);
			addRentDatePropertyDescriptor(object);
			addExpectedReturnDatePropertyDescriptor(object);
			addReturnDatePropertyDescriptor(object);
		}
		return itemPropertyDescriptors;
	}

	/**
	 * This adds a property descriptor for the Renter feature. <!--
	 * begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	protected void addRenterPropertyDescriptor(Object object) {
		itemPropertyDescriptors
				.add(createItemPropertyDescriptor(
						((ComposeableAdapterFactory) adapterFactory)
								.getRootAdapterFactory(), getResourceLocator(),
						getString("_UI_RentRecord_renter_feature"), getString(
								"_UI_PropertyDescriptor_description",
								"_UI_RentRecord_renter_feature",
								"_UI_RentRecord_type"),
						LibraryPackage.Literals.RENT_RECORD__RENTER, true,
						false, true, null, null, null));
	}

	/**
	 * This adds a property descriptor for the Book feature. <!-- begin-user-doc
	 * --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	protected void addBookPropertyDescriptor(Object object) {
		itemPropertyDescriptors.add(createItemPropertyDescriptor(
				((ComposeableAdapterFactory) adapterFactory)
						.getRootAdapterFactory(), getResourceLocator(),
				getString("_UI_RentRecord_book_feature"), getString(
						"_UI_PropertyDescriptor_description",
						"_UI_RentRecord_book_feature", "_UI_RentRecord_type"),
				LibraryPackage.Literals.RENT_RECORD__BOOK, true, false, true,
				null, null, null));
	}

	/**
	 * This adds a property descriptor for the Rent Date feature. <!--
	 * begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	protected void addRentDatePropertyDescriptor(Object object) {
		itemPropertyDescriptors.add(createItemPropertyDescriptor(
				((ComposeableAdapterFactory) adapterFactory)
						.getRootAdapterFactory(), getResourceLocator(),
				getString("_UI_RentRecord_rentDate_feature"), getString(
						"_UI_PropertyDescriptor_description",
						"_UI_RentRecord_rentDate_feature",
						"_UI_RentRecord_type"),
				LibraryPackage.Literals.RENT_RECORD__RENT_DATE, true, false,
				false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
	}

	/**
	 * This adds a property descriptor for the Expected Return Date feature.
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	protected void addExpectedReturnDatePropertyDescriptor(Object object) {
		itemPropertyDescriptors.add(createItemPropertyDescriptor(
				((ComposeableAdapterFactory) adapterFactory)
						.getRootAdapterFactory(), getResourceLocator(),
				getString("_UI_RentRecord_expectedReturnDate_feature"),
				getString("_UI_PropertyDescriptor_description",
						"_UI_RentRecord_expectedReturnDate_feature",
						"_UI_RentRecord_type"),
				LibraryPackage.Literals.RENT_RECORD__EXPECTED_RETURN_DATE,
				true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
				null, null));
	}

	/**
	 * This adds a property descriptor for the Return Date feature. <!--
	 * begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	protected void addReturnDatePropertyDescriptor(Object object) {
		itemPropertyDescriptors.add(createItemPropertyDescriptor(
				((ComposeableAdapterFactory) adapterFactory)
						.getRootAdapterFactory(), getResourceLocator(),
				getString("_UI_RentRecord_returnDate_feature"), getString(
						"_UI_PropertyDescriptor_description",
						"_UI_RentRecord_returnDate_feature",
						"_UI_RentRecord_type"),
				LibraryPackage.Literals.RENT_RECORD__RETURN_DATE, true, false,
				false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
	}

	/**
	 * This returns RentRecord.gif. <!-- begin-user-doc --> <!-- end-user-doc
	 * -->
	 */

	public Object getImage(Object object) {
		return overlayImage(object, getResourceLocator().getImage(
				"custom/rentrecord"));
		// return overlayImage(object,
		// getResourceLocator().getImage("full/obj16/RentRecord"));
	}

	/**
	 * This returns the label text for the adapted class. <!-- begin-user-doc
	 * --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */

	public String getText(Object object) {
		Date labelValue = ((RentRecord) object).getRentDate();
		String label = labelValue == null ? null : labelValue.toString();
		return label == null || label.length() == 0 ? getString("_UI_RentRecord_type")
				: getString("_UI_RentRecord_type") + " " + label;
	}

	/**
	 * This handles model notifications by calling {@link #updateChildren} to
	 * update any cached children and by creating a viewer notification, which
	 * it passes to {@link #fireNotifyChanged}. <!-- begin-user-doc --> <!--
	 * end-user-doc -->
	 * 
	 * @generated
	 */

	public void notifyChanged(Notification notification) {
		updateChildren(notification);

		switch (notification.getFeatureID(RentRecord.class)) {
		case LibraryPackage.RENT_RECORD__RENT_DATE:
		case LibraryPackage.RENT_RECORD__EXPECTED_RETURN_DATE:
		case LibraryPackage.RENT_RECORD__RETURN_DATE:
			fireNotifyChanged(new ViewerNotification(notification, notification
					.getNotifier(), false, true));
			return;
		}
		super.notifyChanged(notification);
	}

	/**
	 * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s
	 * describing the children that can be created under this object. <!--
	 * begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */

	protected void collectNewChildDescriptors(
			Collection<Object> newChildDescriptors, Object object) {
		super.collectNewChildDescriptors(newChildDescriptors, object);
	}

	/**
	 * Return the resource locator for this item provider's resources. <!--
	 * begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */

	public ResourceLocator getResourceLocator() {
		return LibraryEditPlugin.INSTANCE;
	}

}
